package com.party.mobile.web.controller.mall;

import com.party.common.utils.PartyCode;
import com.party.common.utils.StringUtils;
import com.party.core.model.mall.MallBrand;
import com.party.core.service.mall.IMallBrandService;
import com.party.mobile.web.dto.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 品牌控制器
 * Created by yifeng
 *
 * @date 2018/5/11 0011
 * @time 下午 16:44
 */
@Controller
@RequestMapping("mall/brand")
public class MallBrandController {
    @Autowired
    private IMallBrandService mallBrandService;

    Logger logger = LoggerFactory.getLogger(getClass());

    @ResponseBody
    @RequestMapping("getDetail")
    public AjaxResult getDetail(String id) {
        if (StringUtils.isEmpty(id)) {
            return AjaxResult.error(PartyCode.PARAMETER_ILLEGAL, "品牌编号不能为空");
        }
        try {
            MallBrand mallBrand = mallBrandService.get(id);
            return AjaxResult.success(mallBrand);
        } catch (Exception e) {
            logger.error("品牌详情异常", e);
            return AjaxResult.error(100, "品牌详情异常");
        }
    }
}
